﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using UniMana.Utils.Data;
using UniMana.Data;

namespace UniMana.Win.Systems
{
    public partial class FrmUserList : DevExpress.XtraEditors.XtraForm
    {
        public delegate void PassData(DataTable dt);
        public PassData passData;
        DataTable m_dt;
        public FrmUserList()
        {
            InitializeComponent();
            LoadData();
        }
        void LoadData()
        {
            lueCatalogue_Department.GetData(Catalogue_DepartmentData.GetList());
            grcListUser.DataSource = System_UserData.GetList();

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            m_dt = new DataTable();
            if (m_dt.Columns.Count == 0)
            {
                m_dt.Columns.Add("System_UserKey");
                m_dt.Columns.Add("UserName");
            }

            foreach (int i in grvListUser.GetSelectedRows())
            {
                DataRow dr = m_dt.NewRow();
                dr["System_UserKey"]= grvListUser.GetRowCellValue(i, "System_UserKey");
                dr["UserName"] = grvListUser.GetRowCellValue(i, "UserName");
                m_dt.Rows.Add(dr);
            }

            if (m_dt!= null)
            {
                passData(m_dt);
            }

            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}